/******************************************************************************
*  author: enquanyan
*  version: 1.0
*  description: global variable definition
*  date: 2014-07-21
*  other: 无
******************************************************************************/

#ifndef DEF_H
#define DEF_H

enum METHOD
{
	GET = 0, POST, HEAD, PUT, DELETE, TRACE, OPTIONS, CONNECT, PATCH
};

enum CHECK_STATE {
	PARSE_REQUESTLINE_STATE = 0,
	PARSE_HEADER_STATE,
	PARSE_POST_CONTENT_HEADER_STATE,
	PARSE_CONTENT_STATE,
	PARSE_POST_CONTENT_STATE,
    
    PARSE_RESPONSELINE_STATE,
    PARSE_RESPONSE_HEADER_STATE,
    PARSE_RESPONSE_CONTENT_STATE
};

enum HTTP_CODE {
	UNCOMPLETE_REQUEST,//not complete this state yet
	GO_TO_NEXT, // go to next state
	HANDLE_REQUEST,
	ERROR_REQUEST,
	BAD_REQUEST,
	NO_RESOURCE,
	FORBIDDEN_REQUEST,
	FILE_REQUEST,
	FILE_EXIST_REQUEST,
	INTERNAL_ERROR,
	CLOSED_CONNECTION,
	LIST_DIR_REQUEST,
	UPLOAD_FILE_REQUEST,
    FORWARD_FILE_REQUEST,
	RESPONSE_OK,
	RESPONSE_ERROR,
    OPTIONS_REQUEST
};

enum LINE_STATUS {
	LINE_OK = 0, LINE_BAD, LINE_OPEN, LINE_CONTINUE, LINE_FULL
};

enum HANDLE_TYPE {
	READ = 0, WRITE
};

enum READ_STATUS {
	READ_OK = 0, BUFF_IS_FULL, PEER_CLOSED, READ_ERROR
};

const int FILENAME_LEN = 512;
const int LISTDIRCONTENT_LEN = 1024;
const int READ_BUFFER_SIZE = 1024;
const int WRITE_BUFFER_SIZE = 1024;

extern char doc_root[50];

extern char UPLOAD_STRING[50];

extern char FORWARD_STRING[50];

extern char DOWNLOAD_STRING[50];

extern char REMOTE_IP[20];

extern int REMOTE_PORT;

extern int LOCAL_PORT;

extern bool is_use_forward;

extern char REDIRECT_HOST[50];

//#define DEBUG_SWITCH 0 /*any num is the same, if use debug, uncomment this line*/
#ifdef DEBUG_SWITCH
	#define pr_debug(fmt,args...) printf(fmt, ##args)
#else
	#define pr_debug(fmt,args...) /*do nothing */
#endif

#endif
